package org.thread;

import com.google.common.util.concurrent.*;

import javax.annotation.Nullable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;

public class FutureFinal {

    private static final ThreadPoolExecutor EXECUTOR = ThreadPoolFactory.getPool("test");


    private static final ListeningExecutorService LISTENING_EXECUTOR_SERVICE = MoreExecutors.listeningDecorator(EXECUTOR);


    public static void main(String[] args){
//        Future<Integer> future =  EXECUTOR.submit(()->{
//            return 100;
//        });


        ListenableFuture<Integer> listenableFuture =  LISTENING_EXECUTOR_SERVICE.submit(()->{
//            throw new RuntimeException("报错了");
            return 100;
        });

//        listenableFuture.addListener(new Runnable() {
//            @Override
//            public void run() {
//                try {
//                    //到达这里已经执行完成
//                    listenableFuture.get();
//                } catch (InterruptedException e) {
//                    throw new RuntimeException(e);
//                } catch (ExecutionException e) {
//                    throw new RuntimeException(e);
//                }
//            }
//        },EXECUTOR);


//d
    }

}
